package controler;
import java.awt.event.FocusListener;
import java.awt.event.FocusEvent;

import javax.swing.JTextField;

import template.AbstractListener;

import model.Delivery;



import java.util.Observable;

public class SetDeliveryInfoListener extends AbstractListener implements FocusListener{
	
	private static final long serialVersionUID = 1L;
	
	public SetDeliveryInfoListener(Observable obs){
		addModel(obs);
	}
	
	@Override
	public void focusGained(FocusEvent evt){
		Delivery model = (Delivery)getModel(0);
		JTextField source = (JTextField)evt.getSource();
		model.setDeliveryInfo(source.getName(), source.getText());
	}
	
	@Override
	public void focusLost(FocusEvent evt){
		Delivery model = (Delivery)getModel(0);
		JTextField source = (JTextField)evt.getSource();
		model.setDeliveryInfo(source.getName(), source.getText());
	}
}
